function rad=toRadians(degrees)
	rad=degrees*pi/180
endfunction

function root=radius(x,y)
    root=sqrt(power(x, 2) + power(y, 2))
endfunction

function r=earthRadius(latitude)
    theta = toRadians(latitude)
    m = radius(power(a, 2) * cos(theta), power(b, 2) * sin(theta))
    n= radius(a * cos(theta), b * sin(theta))
    r=m/n
endfunction

function dis=distance(lat1,long1,lat2,long2)
    dis=2* earthRadius(lat1) * asin(sqrt(power(sin((toRadians(lat2-lat1))/2),2)+cos(toRadians(lat1))*cos(toRadians(lat2))*power(sin((toRadians(long2-long1))/2),2)))
endfunction
